<?php
    require_once('__common.php');
    $year = isset($_GET['year'])? $_GET['year'] : date('Y');
    $month = isset($_GET['month'])? $_GET['month'] : date('m');
    $no = $_GET['no'];
    
    $arr = getDb('book', $no, 'no');
    extract($arr);

    $sql  = "SELECT * FROM course WHERE bookcode = $no AND year = $year AND month = $month";
    $res  = mysql_query($sql);

    $courses = array();
    $i = 1;
    while($temp = mysql_fetch_assoc($res)) {
            $temp['count'] = $i++;
            $temp['time'] = $temp['starttime'];
        if($temp['time'] > 12) {
            $div[0] = $div[1] = '오후';
            $temp['time'] = $temp['time'] - 12;
            $temp['endtime'] = $temp['time']+1;
            if($temp['endtime'] > 12) {
                $div[] = '오전';
            } 
        } else {
            $div[0] = $div[1] = '오전';
            $temp['endtime'] = $temp['time']+1;
            if($temp['endtime']  > 12) {
               $div[1] = '오후'; 
            }
        }
            $temp['time'] = $div[0]. " ".$temp['time']++.'시~'.$div[1]." ".$temp['time'].'시';
            $courses[] = $temp;

    }

    $price = number_format($price);



    $yearSelcted = array($year => 'selected = "selected"');
    $monthSelcted = array($month => 'selected = "selected"');

    $yearSelect = '';
    for($i = 2008; $i <= date('Y'); $i++){ 
            $yearSelect .= "<option value=\"$i\" $yearSelcted[$i]>{$i}년</option>";

    }
    $monthSelect = '';
        for($i = 1; $i <= 12; $i++){ 
                $monthSelect .= "<option value=\"$i\" $monthSelcted[$i]>{$i}월</option>";

        }
    $tpl->print_('basic');
